<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="keywords" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>地址信息</title>
	<link rel="stylesheet" type="text/css" href="css/dizist.css">
	<link href="css/bootstrap.min.css" rel="stylesheet">
	<link href="css/style1.css" rel="stylesheet">
   <script src="js/jquery.min.js"></script>
   <script src="js/bootstrap.min.js"></script>
<!--必要样式-->
<link rel="stylesheet" type="text/css" href="css/menu_elastic.css" />
    <script src="js/vue.js"></script>
<script src="js/snap.svg-min.js"></script>
<!--[if IE]>
    <script src="js/html5.js"></script>
    <![endif]-->
</head>
<body class="huibg">
<div id="el">
<div class="menu-wrap">
    <nav class="menu">
      <div class="icon-list">
          <!--店铺首页-->
        <a href="index.html"><i class="iconfont icon-home"></i><span>首页</span></a>
        <a href="/weixin/queryIndex"><i class="iconfont icon-yonghux"></i><span>个人中心</span></a>
        <a href="ddcenter.html"><i class="iconfont icon-liebiao"></i><span>订单中心</span></a>
        <a href="dizhi.html"><i class="iconfont icon-dizhi"></i><span>地址信息</span></a>
      </div>
    </nav>
    <button class="close-button" id="close-button">Close Menu</button>
    <div class="morph-shape" id="morph-shape" data-morph-open="M-1,0h101c0,0,0-1,0,395c0,404,0,405,0,405H-1V0z">
      <svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 100 800" preserveAspectRatio="none">
        <path d="M-1,0h101c0,0-97.833,153.603-97.833,396.167C2.167,627.579,100,800,100,800H-1V0z"/>
      </svg>
    </div>
  </div>
<nav class="navbar text-center">
   <button class="topleft" onclick ="javascript:history.go(-1);"><span class="iconfont icon-fanhui"></span></button>
  <a class="navbar-tit center-block">地址信息</a>
 <!-- <button class="topnav" id="open-button"><span class="iconfont icon-1"></span></button>-->
</nav>


<div class="usercenter">
  <div class="cdv">
    <a href="newdizhi.html"><span>新建地址</span></a>
  </div>
    <div v-html="addresses">
 <!-- <div class="cdv dzi">
      <p>收货人：陆芒星 <button class="label label-danger pull-right">默认</button></p>
      <p>手机：138****777</p>
      <p>所在地区：上海市宝山区</p>
      <p>地址：长江南路170号长江软件园516室</p>
      <a href="dizhipage.html" style="color: red">编辑地址</a>
  </div>-->
        </div>
</div>

    <div style="height: 50px;"> </div>

    <div class="footnav" style="z-index: 999">
        <div class="col-xs-3 text-center"><a href="/weixin/shoppingMall"><i class="iconfont icon-shop"></i><p>商城</p></a></div>
        <div class="col-xs-3 text-center"><a href="details.html"><i class="iconfont icon-huodongfj"></i><p>关于我们</p></a></div>
        <div class="col-xs-3 text-center"><a href="/weixin/shoppingmall/my-order.html"><i class="iconfont icon-liebiao"></i><p>订单中心</p></a></div>
        <div class="col-xs-3 text-center"><a href="mendian.html"><i class="iconfont icon-dizhi"></i><p>附近门店</p></a></div>
    </div>
    </div >
<script src="js/classie.js"></script>
<script src="js/main3.js"></script>
<script>
    var updateDefaultAddress=function(data){
        var id=$(data).attr("did");
        id=parseInt(id)
        $.ajax({
            url:`/weixin/updateDefaultAddress/${id}`,
            data:{},
            dataType: "json",
            type:"get",
            success:function(data){
                if(data.obj.trim()=="success"){
                    var a=window.location.href;
                    window.location.href=a;
                }
            }
        })
    }
    var vue=new Vue({
        el:"#el",
        data:{
            addresses:""
        },
        created:function(){
         this.queryUserAdress();
        },
        methods:{
            queryUserAdress:function(data){
                var _this=this;
                $.ajax({
                    url: "/weixin/queryUserAddress",
                    data:{},
                    dataType:"json",
                    type:"get",
                    success:function(data){
                      if(data.obj==null){
                          alert("请关注公众号后再进行操作"),
                              window.location.href="/weixin/queryIndex"
                      }else{
                          if(data.li!=null || data.li.length!=0){
                              var e="";
                              for(var i=0;i<data.li.length;i++){
                                  if(data.li[i].isdefault==1 ||data.li.isdefault=="1"){
                                      e=e+`<div class="cdv dzi">
                                      <p>收货人：${data.li[i].name} <button class="label label-danger pull-right">默认地址</button></p>
                                  <p>手机：${data.li[i].tel}</p>
                                  <p>地址：${data.li[i].addr}</p>
                                  <a href="dizhipage.html?id=${data.li[i].userAddressId}" style="color: red">编辑地址</a>
                                      </div>`}else{
                                      e=e+`<div class="cdv dzi">
                                      <p>收货人：${data.li[i].name} <button class="label label-danger pull-right" did="${data.li[i].userAddressId}" onclick=updateDefaultAddress(this)>设为默认</button></p>
                                  <p>手机：${data.li[i].tel}</p>
                                  <p>地址：${data.li[i].addr}</p>
                                  <a href="dizhipage.html?id=${data.li[i].userAddressId}" style="color: red">编辑地址</a> </div>`
                                  }
                              }
                              _this.addresses=e;
                          }
                      }
                    }
                })
            }


        }
    });
</script>
</body>
</html>